package com.atguigu08._interface.apply;

public class USBTest {
    public static void main(String[] args) {
        Computer computer=new Computer();
        Mouse mouse=new Mouse();
        computer.work(mouse);

        //3.创建接口匿名实现类的对象
        USB usb1 =new USB(){
            public void start(){
                System.out.println("U盘开始工作"); }

            public void end(){
                System.out.println("U盘结束工作"); }
    };
            computer.work(usb1);
//4．创建接口匿名实现类的匿名对象
        computer.work(new USB(){
            public void start() {
                System.out.println("扫描仪开始工作");
            }
            public void end() {
                System.out.println("扫描仪结束工作");
            }
        }  );
        System.out.println("-------------");
        KeyBoard keyBoard=new KeyBoard();
        computer.work(keyBoard);
        System.out.println("-------------");
        computer.work(new deB());

    }
}

interface USB{
    public static final int number = 0;
    void start();
    void end();
}

class Computer{
    public void work(USB usb){//多态性
        System.out.println("设备启动中");
        usb.start();
        System.out.println("执行操作");
        usb.end();
    }
}

class Mouse implements USB{
    @Override
    public void start() {
        System.out.println("鼠标开始");
    }

    @Override
    public void end() {
        System.out.println("鼠标结束");
    }
}

class KeyBoard extends Mouse{
    @Override
    public void start() {
        System.out.println("键盘开始");
    }
    public void end() {
        System.out.println("键盘结束");
    }
}

abstract class deA implements USB {

    @Override
    public void start() {
        System.out.println("a start");
    }
}

class deB extends deA{
    public void start() {
        System.out.println("b start");
    }

    @Override
    public void end() {

    }
}